import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_refresh.dart';
import 'package:honeypotflutter/public/views/public_tabBar_scrollView.dart';
import '../../help/package_help.dart';
import '../package_list/view.dart';
import '../package_retention_list/view.dart';
import 'logic.dart';

class PackageRetentionPage extends StatefulWidget {
  final int? deviceId;
  const PackageRetentionPage({
    Key? key,
    this.deviceId,
  }) : super(key: key);

  @override
  State<PackageRetentionPage> createState() => _PackageRetentionPageState();
}

class _PackageRetentionPageState extends State<PackageRetentionPage> {
  final PackageRetentionLogic logic = Get.put(PackageRetentionLogic());
  final HLRefreshController waitPackageController = HLRefreshController(initialRefresh: true);
  final HLRefreshController retentionPackageController = HLRefreshController(initialRefresh: true);
  int? deviceID;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    deviceID = Get.arguments;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "包裹查询"),
      body: HLTabBarScrollView(
        mens: ["滞留件", "待取件"],
        children: [
          PackageRetentionListPage(
              refreshController: retentionPackageController,
              deviceId: deviceID,
              recallPackageAction: () {
                waitPackageController.requestRefresh();
                retentionPackageController.requestRefresh();
              },
              modifyPhoneAction: () {
                waitPackageController.requestRefresh();
              }),
          PackageListPage(
            type: PackageType.waitPackage,
            refreshController: waitPackageController,
            deviceId: deviceID,
            recallPackageAction: () {
              waitPackageController.requestRefresh();
              retentionPackageController.requestRefresh();
            },
            modifyPhoneAction: () {
              retentionPackageController.requestRefresh();
            },
          ),
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<PackageRetentionLogic>();
    super.dispose();
  }
}
